Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bullets

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bullets

Generate a plain-text and markdown formatted lists or tables of contents, with proper indentation, bullets, numbers, letters, roman numerals or custom characters.

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

bullets NPM version

Generate a plain-text and markdown formatted lists or tables of contents, with proper indentation, bullets, numbers, letters, roman numerals or custom characters.

Install with npm

npm i bullets --save

Usage

var bullets = require('bullets');

Example

Roman numerals

var list = [
  {text: 'Item a...', lvl: 0}, 
  {text: 'Item b...', lvl: 1}, 
  {text: 'Item c...', lvl: 2},
  {text: 'Item d...', lvl: 2},
  {text: 'Item e...', lvl: 2},
];

// let's generate 100 numerals, in case our list grows.
var actual = bullets(list, {chars: '1..100'}, function (ch) {
  return romanize(ch) + '.';
});

Results in:

I. Item a...
  II. Item b...
    III. Item c...
    III. Item d...
    III. Item e...

API

list

Pass an array of list-item objects to generate a formatted list or table of contents. Uses list-item for generating the actual items.

  • list {Array}: Array of item objects with text and lvl properties
  • opts {Object}: Options to pass to list-item.
  • fn {Function}: pass a function expand-range to modify the bullet for an item as it's generated.
var list = [
  {text: 'This is item 1', lvl: 0},
  {text: 'This is item 2', lvl: 0},
  {text: 'This is item 3', lvl: 0},
  {text: 'This is sub-item A', lvl: 2},
  {text: 'This is sub-item B', lvl: 2},
  {text: 'This is sub-item C', lvl: 2},
];
bullets([{text: 'This is a list item', lvl: 0}]);

// Results in
// '- This is item 1'
// '- This is item 2'
// '- This is item 3'
// '  * This is sub-item A'
// '  * This is sub-item B'
// '  * This is sub-item C'

Run tests

Install dev dependencies:

npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Author

Jon Schlinkert

License

Copyright (c) 2015 Jon Schlinkert
Released under the license


This file was generated by verb on February 21, 2015.

Keywords

FAQs

Package last updated on 22 Feb 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc